<?php

$action = getAction();

switch ($action) {
	case "index":
		$page = max(1, intval($_GET['page']));
		$pageSize = 10;
		
		$user = $db->getRow("select * from " . table("user") . " where openid = '$openid'");
		
		$sql = "select * from " . table("point_log") . " where user_id = " . $user["id"] . " order by insert_time desc";
		$pageData = getPageData($db, $sql, $page, $pageSize);

		for($i = 0; $i < count($pageData["list"]); $i++) {
			$msg = POINT_TYPE::getTypeName($pageData["list"][$i]["point_type"]);
			
			if($pageData["list"][$i]["use_flag"]) {
				$msg .= "支出";
			}else {
				$msg .= "获得";
			}
			
			$msg .= $pageData["list"][$i]["point"] . "积分";
			
			$pageData["list"][$i]["msg"] = $msg;
		}
		
		
		$smarty->assign("user", $user);
		$smarty->assign("pageData", $pageData);
		$smarty->display("point.html");
		break;
	case "rule":
		$smarty->display("point_rule.html");
		break;
}
?>